package com.agentfactory.teleoreactive.interpreter.mentalstate;

import com.agentfactory.logic.update.lang.IFormula;
import com.agentfactory.logic.update.reasoner.Bindings;
import com.agentfactory.teleoreactive.interpreter.Utilities;

public class TRRule {
	private IFormula condition;
	private IFormula action;
	
	public TRRule(IFormula condition, IFormula action){
		this.condition = condition;
		this.action = action;
	}
	/**
	 * Returns the condition which must be satisfied to fire the rule.
	 * @return The condition to be queried by the interpreter.
	 */
	public IFormula getCondition(){
		return condition;
	}
	/**
	 * Returns the action which performed in the event the rule is satisfied.
	 * @return The action which the interpreter performs.
	 */
	public IFormula getAction(){
		return action;
	}
	/**
	 * Produces string representation of the rule.
	 */
	public String toString(){
		String ret = Utilities.presenter.toString(condition) + "->" + Utilities.presenter.toString(action);
		return ret;
	}
	
	/**
	 * Applies a set of bindings to the parameters of the rule
	 * @param A set of Bindings
	 * @return A new TRRule bound to the set provided
	 */
	public TRRule apply(Bindings set){
		return new TRRule(condition.apply(set), action.apply(set));
	}
	
}
